<template>
  <div class="app-container">

    <!--查询表单-->
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item>
        <el-input v-model="teamQuery.name" placeholder="球队名称"/>
      </el-form-item>

      <el-form-item>
        <el-input v-model="teamQuery.coach" placeholder="球队教练"/>
      </el-form-item>

      <el-form-item label="添加时间">
        <el-date-picker
          v-model="teamQuery.begin"
          type="datetime"
          placeholder="选择开始时间"
          value-format="yyyy-MM-dd HH:mm:ss"
          default-time="00:00:00"
        />
      </el-form-item>
      <el-form-item>
        <el-date-picker
          v-model="teamQuery.end"
          type="datetime"
          placeholder="选择截止时间"
          value-format="yyyy-MM-dd HH:mm:ss"
          default-time="00:00:00"
        />
      </el-form-item>

      <el-button type="primary" icon="el-icon-search" @click="getList()">查询</el-button>
      <el-button type="default" @click="resetData()">清空</el-button>
    </el-form>


    <!-- 表格 -->
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="数据加载中"
      border
      fit
      highlight-current-row>

      <el-table-column
        label="序号"
        width="70"
        align="center">
        <template slot-scope="scope">
          {{ (page - 1) * limit + scope.$index + 1 }}
        </template>
      </el-table-column>

      <el-table-column prop="name" label="队伍名称" width="200" />

      <el-table-column prop="coach" label="教练名称" width="200" />

      <el-table-column prop="groupRank" label="小组排名" width="130" />

      <el-table-column prop="score" label="目前得分" width="150" />

      <el-table-column prop="createDate" label="添加时间" width="160"/>

      <el-table-column label="操作" width="400" align="center">
        <template slot-scope="scope">
          <router-link :to="'/player/save/'+scope.row.id">
            <el-button type="primary" size="mini" icon="el-icon-edit">修改</el-button>
          </router-link>
          <el-button type="danger" size="mini" icon="el-icon-delete" @click="removeDataById(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
  import team from '@/api/dbwork/team'
  export default {
    data(){
      return{
        list:null, // 查询之后返回的list
        page:1,
        limit:10,
        total:0,
        teamQuery:{}  // 封装的数据
      }
    },
    created() {
      this.getList()
    },
    methods:{
      getList(page = 1){
        this.page = page
        team.getTeamListPage(this.page,this.limit,this.teamQuery)
          .then(response => {
            // console.log(response)
            this.list = response.data.rows
            this.total = response.data.total
          })
      },
      resetData(){
        this.teamQuery = {}
        this.getList()
      }

    }
  }
</script>
